namespace BM.Tools.WebControls.MForm.Generator
{
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Xml.Schema;

    using BM.Tools.Xml.Schema;

    /// <summary>
    /// FormAttribute is an intermediate class that is created after visiting <see cref="XmlSchemaAttribute" /> node.
    /// </summary>
    public class FormAttribute : FormItem
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FormAttribute"/> class. 
        /// </summary>
        /// <param name="builder">
        /// The builder.
        /// </param>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <param name="schemaAttribute">
        /// The schemaAttribute.
        /// </param>
        public FormAttribute(FormBuilder builder, Visited parent, XmlSchemaAttribute schemaAttribute) : base(builder, parent, schemaAttribute)
        {
            SchemaAttribute = schemaAttribute;
            DefaultValue = schemaAttribute.DefaultValue;
            FixedValue = schemaAttribute.FixedValue;
            IsLeaf = true;
        }

        /// <summary>
        /// Gets ChildrenItems.
        /// </summary>
        /// <value>
        /// The children items.
        /// </value>
        public override Collection<FormItem> ChildrenItems
        {
            get
            {
                return new Collection<FormItem>();
            }
        }

        /// <summary>
        /// Gets SchemaAttribute.
        /// </summary>
        /// <value>
        /// The schema attribute.
        /// </value>
        public XmlSchemaAttribute SchemaAttribute
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets QualifiedName.
        /// </summary>
        public override string QualifiedName
        {
            get
            {
                return LocalName;
            }
        }
    }
}